package com.ruoyi.business.service;


import com.ruoyi.business.domain.CarPackageAudit;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;

import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;

public interface IProcessService {

    Deployment deploy(String filePath) throws FileNotFoundException;

    ProcessDefinition selectProcessDefinitionByDeploymentId(String deploymentId);

    /**
     * 根据部署id查询对应的bpmn文件
     * @param deploymentId
     * @return
     */
    InputStream getResourceAsStream(String deploymentId);

    /**
     * 根据部署id查询对应的png文件
     * @param id
     * @param highLightedActivities
     * @param highLightedFlows
     * @return
     */
    InputStream getProcessImage(String id, List<String> highLightedActivities, List<String> highLightedFlows);

    ProcessInstance startProcessInstance(String definitionKey, String businessKey, HashMap<String, Object> variables);

    /**
     * 根据流程实例ID获取当前的任务节点
     * @param processInstanceId
     * @return
     */
    Task getTaskByProcessInstanceId(String processInstanceId);

    /**
     * 给任务设置候选人
     * @param currentTask
     * @param userId
     */
    void addCandidateUser(Task currentTask, Long userId);

    /**
     * 根据流程实例Id获取流程图
     * @param instanceId
     * @return
     */
    InputStream getProcessImageByInstanceId(String instanceId);

    /**
     * 根据流程实例Id删除
     * @param instanceId
     */
    void deleteProcessInstance(String instanceId);

    long selectTodoTaskCount(String definitionKey, String candidateUser);

    List<Task> selectTodoTaskList(String definitionKey, String candidateUser,Integer firstResult,Integer pageSize);

    /**
     * 根据流程实例id获取实例
     * @param processInstanceId
     * @return
     */
    ProcessInstance getProcessInstanceById(String processInstanceId);

    Task getTaskByTaskId(String taskId);


    void claimAndCompleteTask(Task task, String userId, boolean auditStatus, String comment);

    Task getTaskByInstanceId(String processInstanceId);

    /**
     * 重新申请
     * @param task
     * @param userId
     * @param comment
     */
    void claimAndCompleteTask(Task task, String userId, String comment);

    void setVariable(String taskId, String key, long value);



    long selectDoneTaskCount(String definitionKey, String userId);

    /**
     * 查询对应用户的已办任务
     * @param definitionKey
     * @param userId
     * @param startNum
     * @param pageSize
     * @return
     */
    List<HistoricTaskInstance> selectDoneTaskList(String definitionKey, String userId, Integer startNum, Integer pageSize);

    /**
     * 获取历史流程实例 , 可以获取到对应的业务 Key
     * @param processInstanceId
     * @return
     */
    HistoricProcessInstance getHistoricProcessInstanceById(String processInstanceId);

    List<HistoricActivityInstance> selectHistoryTaskList(String instanceId);

    String getTaskComment(String taskId);
}
